import asyncio
from requests_html import HTMLSession

url  = 'https://passport.baidu.com/v2/?login&tpl=mn&u=http%3A%2F%2Fwww.baidu.com%2F&sms=5'
session = HTMLSession( browser_args=[
        '--no-sand',
        '--disable-infobars'
        '--user-agent=Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36'
    ])
res = session.request(url=url,method='GET')
script = """
                () => {
                    return {
                        width: document.documentElement.clientWidth,
                        height: document.documentElement.clientHeight,
                        deviceScaleFactor: window.devicePixelRatio,
                    }
                }
               """
try:
    res.content
    res.html.render(keep_page = True)
    async def main():
        await res.html.page.waitFor(1000)
        await res.html.page.screenshot({'path': 'login.png2'})
        await res.html.page.click(' [id = "TANGRAM__PSP_3__footerULoginBtn"]')
        await res.html.page.type(' [id="TANGRAM__PSP_3__userName"]','18650180552')
        await res.html.page.type(' [id="TANGRAM__PSP_3__password"]','a7458969')
        await res.html.page.screenshot({'path': 'login.png'})
        await res.html.page.waitFor(1000)
    asyncio.get_event_loop().run_until_complete(main())
except Exception as e:
    print(e)
finally:
    session.close()